package es.juanc.logging.log4j;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.log4j.FileAppender;
import org.apache.log4j.Logger;

public class ConfigLog4jTest {

	static {
		SimpleDateFormat sdf = new SimpleDateFormat("hh-mm-ss_ddMMyyyy");
		System.setProperty("time.log", sdf.format(new Date()));
	}
	private static final Logger log = Logger.getLogger( ConfigLog4jTest.class );

	private static void configureLog() {

		SimpleDateFormat sdf = new SimpleDateFormat("hh-mm-ss_ddMMyyyy");
		String filename = "log/RochadeBus_" + sdf.format( new Date() ) + ".log";
		
		FileAppender appender = (FileAppender)log.getParent().getAppender( "FILE" );
		appender.setFile( filename );
		appender.activateOptions();
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		// BasicConfigurator.configure();
		// BasicConfigurator.resetConfiguration();
		// PropertyConfigurator.configure( "log4j.properties" );

		System.out.println( log.getName() + ", " + log.getLevel() + ", " 
				+ log.getParent().getAppender( "FILE" ) );

		//configureLog();
		
		System.out.println( "..." );
	}
}